PRO lastsub, num1, num2, img1 = img1, img2 = img2, subimg = subimg

impath = 'F:\Research\2004_12_21'
;impath = '/home/arlsrv/nathanic/apo/Q1DD01/UT050108/'
;outpath = impath + 'process/'

IF n_params() LT 2 THEN BEGIN
   files = file_search(impath + '*.????.fits')
   nf = n_elements(files)
   filend = stregex(files, '\.([0-9]{4})\.fits', /extract, /subexpr)
   filenums = reform(filend[1, *])
   ordered = filenums[sort(filenums)]
   n1str = strtrim(ordered[nf-1], 2)
   n2str = strtrim(ordered[nf-2], 2)
ENDIF ELSE BEGIN
   n1str = strtrim(num1, 2)
   n2str = strtrim(num2, 2)
ENDELSE

WHILE strlen(n1str) LT 4 DO n1str = '0' + n1str
WHILE strlen(n2str) LT 4 DO n2str = '0' + n2str

file1 = file_search(impath + '*.' + n1str + '.fits')
file2 = file_search(impath + '*.' + n2str + '.fits')

print, 'READING AND SUBTRACTING FILES:'
print, file1
print, file2

img1 = reverse(float(mrdfits(file1[0], 0, h, /unsigned, /silent)))
img2 = reverse(float(mrdfits(file2[0], 0, h, /unsigned, /silent)))
subimg = img1-img2
atv, subimg

end
